from django.contrib.auth.models import AbstractUser
from django.db import models

class User(AbstractUser):
    phone = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    openid = models.CharField(max_length=100, unique=True, null=True, blank=True, verbose_name='微信openid')
    avatar = models.URLField(verbose_name='头像', null=True, blank=True)
    
    # 设置用户名为登录字段（用于后台管理）
    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['phone']

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = verbose_name
        
    def __str__(self):
        return f'{self.username}({self.phone})' 